package rabbit.aop;

import model.transfer.HappyMoneyVO;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

@Aspect
public class LoggingAspect {
	private ReportDao reportDao;
	public LoggingAspect(ReportDao reportDao){
		this.reportDao=reportDao;
	}
	@Around("execution(public * model.transfer.*Service.transfer(..))")
	public Object report(ProceedingJoinPoint point) throws Throwable{
		Object args[]=point.getArgs();
		HappyMoneyVO hvo=(HappyMoneyVO)args[0];
		int money=hvo.getSendMoney();
		Object retValue=null;
		retValue=point.proceed();
		if(reportDao.showMoney(money)!=null){
			System.out.println("업데이트");
			reportDao.updateCnt(money);
		}else{
			System.out.println("인설트");
			reportDao.insertMoney(money);
		}
		
		
		
		return retValue;
	}
}
